from django.shortcuts import render
# 导入类视图
from django.views import View
# 导入模型类
from .models import *
# 导入响应数据函数
from common.respond.res import res
import datetime


# Create your views here.


# 获取轮播图数据接口
class GetSlides(View):
    def get(self, request):
        slides_list = list(Slides.objects.all().values())
        # 获取全部轮播图数据
        return res(200, "获取成功！", {"data": slides_list})


# 获取首页分类导航数据接口
class GetNavCate(View):
    def get(self, request):
        nav_cate_list = list(NavCate.objects.all().values())
        # 获取分类导航数据
        return res(200, "获取成功！", {"navCateList": nav_cate_list})


# # 获取超值爆款数据
class GetHotNewGoods(View):
    def get(self, request):
        hot_list = list(HotNewGoods.objects.all().values())
        # 获取分类导航数据
        return res(200, "获取成功！", {"hotNewGoods": hot_list})


# 获取上新公告
class GetShopNews(View):
    def get(self, request):
        shop_news_list = list(ShopNews.objects.all().values())
        count = ShopNews.objects.count()
        # 获取分类导航数据
        return res(200, "获取成功！", {"newList": shop_news_list, 'count': count})
